/**
 * 
 * 广州锐鹏计算机科技有限公司（www.ruipengkj.com）
 * 
 * 
 * Copyright (c) 2011-2012 RUIPENGKJ.Co.Ltd. All rights reserved.
 * 
 * */
package com.ruipengkj.service.impl;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.ruipengkj.bean.TJobdeLivery;
import com.ruipengkj.bean.TResume;
import com.ruipengkj.bean.TTexperience;
import com.ruipengkj.commons.base.query.PageModel;
import com.ruipengkj.dao.TResumeDao;
import com.ruipengkj.service.TResumeService;
/**
 * 说明：
 * 单据商品明细Service层接口实现
 * @Author：李智深
 * @Date：2012-03-16
 */
@Service
public class TResumeServiceImpl implements TResumeService{
	@Resource
	private TResumeDao tResumeDao;//DAO层
	//查询所有
	@Override
	public List<TResume> findService(TResume entity) throws Exception {
		String hql = "select o from TResume o";
		StringBuffer whereHQL = new StringBuffer();
		List<Object> param = new ArrayList<Object>();
		if (entity != null) {
			if(whereHQL.length()>4)
				whereHQL.delete(whereHQL.length()-5, whereHQL.length());
		}
		LinkedHashMap<String, String> orderby = new LinkedHashMap<String, String>();
		return tResumeDao.findDao(hql, whereHQL.toString(), param, orderby);
	}
	//根据ID翻页查询
	@Override
	public PageModel<TResume> getScrollService(int firstResult,
			int maxResult, TResume entity) throws Exception {
		String hql = "select o from TResume o";
		StringBuffer whereHQL = new StringBuffer();
		List<Object> param = new ArrayList<Object>();
		if (entity != null) {
			if(whereHQL.length()>4)
				whereHQL.delete(whereHQL.length()-5, whereHQL.length());
		}
		LinkedHashMap<String, String> orderby = new LinkedHashMap<String, String>();
		return tResumeDao.getScrollDao(hql, whereHQL.toString(), param, firstResult, maxResult, orderby);
	}
	//修改
	@Override
	public void modifyService(TResume entity) throws Exception {
		tResumeDao.modifyDao(entity);
		
	}
	//添加
	@Override
	public void saveService(TResume entity) throws Exception {
		tResumeDao.saveDao(entity);
	}
	//根据ID删除
	@Override
	public void deleteService(String id) throws Exception {
		tResumeDao.deleteDao(id);
		
	}
	//根据ID查询
	@Override
	public TResume getByIdService(String id) throws Exception {
		return tResumeDao.getByIdDao(id);
	}
	//添加或修改
	@Override
	public void saveOrUpdateService(TResume entity) throws Exception {
		tResumeDao.saveOrUpdateDao(entity);
	}
	//添加返回ID
	@Override
	public Serializable saveRetService(TResume entity) throws Exception {
		return tResumeDao.saveRetDao(entity);
	}
	public TResumeDao getTFeeDao() {
		return tResumeDao;
	}

	public void setTFeeDao(TResumeDao tResumeDao) {
		this.tResumeDao = tResumeDao;
	}
	
	
	
	@Override
	public PageModel<TResume> getResumeList(int firstResult, int maxResult,
			TJobdeLivery entity) throws Exception {
//		String hql = "select o from TResume o ";
//		StringBuffer whereHQL = new StringBuffer();
//		List<Object> param = new ArrayList<Object>();
//		if (entity != null) {
//			if(entity.getJobID()!=null&&!entity.getJobID().equals("")){
//				whereHQL.append("o.TJobdeLivery.jobID = ?");
//				param.add(entity.getJobID());
//			}
		
		String hql = "select o from TResume o left join o.TJobdeLivery as o2";
		StringBuffer whereHQL = new StringBuffer();
		List<Object> param = new ArrayList<Object>();
		if (entity != null) {
			if(entity.getJobID()!=null&&!entity.getJobID().equals("")){
				whereHQL.append("o2.TResume.resumeID=o.resumeID and o2.jobID = ?");
				param.add(entity.getJobID());
			}
//		
//			if(whereHQL.length()>4)
//				whereHQL.delete(whereHQL.length()-5, whereHQL.length());
		}
		
		LinkedHashMap<String, String> orderby = new LinkedHashMap<String, String>();
		return tResumeDao.getScrollDao(hql, whereHQL.toString(), param, firstResult, maxResult, orderby);
	}
	
	
	//查看工作经验
	@Override
	public PageModel<TResume> getTTexperienceList(int firstResult, int maxResult,
			TTexperience entity) throws Exception {

//		
//		String hql = "select o from TResume o left join o.TTexperience as o2";
//		StringBuffer whereHQL = new StringBuffer();
//		List<Object> param = new ArrayList<Object>();
//		if (entity != null) {
//			if(entity.getTResume().getResumeID()!=null&&!entity.getTResume().getResumeID().equals("")){
//				whereHQL.append("o2.TResume.resumeID=o.resumeID and o2.TResume.resumeID = ?");
//				param.add(entity.getTResume().getResumeID());
//			}
//		}
//		
//		LinkedHashMap<String, String> orderby = new LinkedHashMap<String, String>();
//		return tResumeDao.getScrollDao(hql, whereHQL.toString(), param, firstResult, maxResult, orderby);
		return null;
	}
	
	
	
	
	
	
	
	
}